import React ,{Component} from "react"
import {Image,FlatList,StyleSheet,Text,View,Button,TextInput,Modal,TouchableOpacity} from "react-native"
import {Actions} from "react-native-router-flux"
import {connect} from "react-redux";
import * as USER_ACTION from "../../actions/userAction";
var REQUEST_URL = "http://m.maoyan.com/ajax/movieOnInfoList?token=";

import sAdapter from '../../tools/screenAdapter'

class Loading extends Component{
    constructor(props) {
        super(props);
        this.state = {
            inHot:1,
            footerTab:0,
            showModal:false
        };
        this.loginReq = this.loginReq.bind(this);
        this.closeModal = this.closeModal.bind(this);

    }

    loginReq(){
        this.props.__LOGIN("myname","mypwd");
    }

    componentWillUnmount(): void {
        this.setState({
            showModal:false
        })
    }


    closeModal(){
        this.setState({
            showModal:false
        })
    }

    render(): React.ReactNode {

        return <View style={styles.page}>
            <TouchableOpacity onPress={()=>{
                Actions.pop();
            }} style={styles.container}>

                <Image style={styles.loadGif} source={require('../../res/img/loading.gif')} />
            </TouchableOpacity>
        </View>;
    }

}

var styles = StyleSheet.create({
    page:{
        position:"absolute",
        top:0,
        left:0,
        height: sAdapter.height,
        width: sAdapter.width,
        transform:sAdapter.transform,
        backgroundColor: "rgba(0,0,0,0.2)",
    },
    container:{
        borderRadius:4,
        marginLeft:"auto",
        marginRight:"auto",
        backgroundColor: "rgba(255,255,255,0.5)",
        justifyContent:"center",
        marginTop:sAdapter.height/2
    },
    loadGif:{
        marginRight: "auto",
        marginLeft: "auto"
    }

});

export default connect(
    (state) => {
        return {
            $$USERNAME:state.user.username,
            $$PWD:state.user.pwd,
            $$loadingStatus:state.root.loadingStatus
        }
    },
    (dispatch) => ({

        __LOGIN: (username,pwd) => dispatch(USER_ACTION.login(username,pwd)),

    })
)(Loading)